<?php
/**
 * Created by PhpStorm.
 * User: xsp
 * Date: 2018/5/11
 * Time: 17:43
 */

namespace backend\controllers;


use yii\filters\AccessControl;
use yii\filters\VerbFilter;
use yii\web\Controller;

class CommonController extends Controller
{

    protected $actions = ['*'];
    protected $except = [];
    protected $mustLogin = [];
    protected $verbs = [];
    public function behaviors()
    {
//       var_dump(\Yii::$app->admin->isGuest);
     return[
         'access'=>[
             'class'=>AccessControl::className(),
             'only'=>$this->actions,
             'except'=>$this->except,
             'user'=>'admin',
             'rules' =>[
                [
                    'allow'=>false,
                    'actions'=>$this->mustLogin,
                     'roles'=>['?'],
                ],
                 [
                     'allow'=>true,
                     'actions'=>$this->mustLogin,
                     'roles'=>['@']
                 ],
             ]
         ],
         'verbs'=>[
             'class'=>VerbFilter::className(),
             'actions'=>$this->verbs
         ]
     ];
    }

}